import request from '../utils/request'

/**
 * 发送注册验证码
 */
export function sendRegisterCode(phone) {
  return request({
    url: '/phone/send-register-code',
    method: 'post',
    data: { phone }
  })
}

/**
 * 发送登录验证码
 */
export function sendLoginCode(phone) {
  return request({
    url: '/phone/send-login-code',
    method: 'post',
    data: { phone }
  })
}

/**
 * 验证注册验证码
 */
export function verifyRegisterCode(phone, code) {
  return request({
    url: '/phone/verify-register-code',
    method: 'post',
    data: { phone, code }
  })
}

/**
 * 验证登录验证码
 */
export function verifyLoginCode(phone, code) {
  return request({
    url: '/phone/verify-login-code',
    method: 'post',
    data: { phone, code }
  })
}

/**
 * 检查手机号是否已注册
 */
export function checkPhone(phone) {
  return request({
    url: `/phone/check-phone/${phone}`,
    method: 'get'
  })
}
